package org.opsliframework.boot.imp;

import com.aliyun.tea.TeaException;
import com.douyin.openapi.client.Client;
import com.douyin.openapi.client.models.*;
import com.douyin.openapi.credential.models.Config;
import org.opsliframework.boot.DouYin;
import org.opsliframework.boot.tool.R;

/**
 * 抖音实现类
 */
public class Douyin implements DouYin {
    @Override
    public R<?> verification(String appid, String appsecret, String code, String grant_type) {
        try {
            Config config = new Config().setClientKey("test_app_id").setClientSecret("test_app_secret");
            Client client = new Client(config);
            // 调用 API

            CertificatePrepareRequest certificatePrepareRequest = new CertificatePrepareRequest()
                    .setAccessToken("test_access_token")
                    .setCode("卷码铭文").setPoiId("门店id")
                    .setEncryptedData("从二维码解析出来的标识传参前需要先进行URL编码，注意不要有空格)");
            CertificatePrepareResponse sdkRequest = client.CertificatePrepare(certificatePrepareRequest);
            System.out.println(sdkRequest);
        } catch (TeaException e) {
            System.out.println(e.getMessage());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }


        return null;
    }


    public R<?> verification2(String appid, String appsecret, String code, String grant_type) {
        try {
            Config config = new Config().setClientKey("test_app_id").setClientSecret("test_app_secret");
            Client client = new Client(config);
            // 调用 API

            CertificateVerifyRequest certificateVerifyRequest = new CertificateVerifyRequest()
                    .setAccessToken("test_access_token")
                    .setVerifyToken("卷码铭文")
                    .setPoiId("门店id");
            CertificateVerifyResponse sdkRequest = client.CertificateVerify(certificateVerifyRequest);
            System.out.println(sdkRequest);
        } catch (TeaException e) {
            System.out.println(e.getMessage());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }


        return null;
    }
}
